#

| Chapter 6 Shell and Environment Variables |

## 6.7 What Time Is It in Japan?

tm | The TZ (6.6) environment variable has some convenient uses, particularly if you do business with people scattered all over the globe. Let's say you want to call your trading partner in Japan to find out how the stock exchange is doing. But you want to know, first, whether or not the market has opened (or whether your partner is even awake!). You can use a shell script called tm that does this for you. Or you can (quickly) set TZ to "Japan," print the date, and reset TZ. Here are examples - including resetting TZ temporarily (6.10) in the Bourne and C shells:

    ( ) ;
    % date
    Tue Mar  4 20:48:58 EST 1997
    % tm Japan
    Wed Mar  5 10:48:07 JST 1997

    %(setenv TZ Japan; date)
    Wed Mar  5 10:48:13 JST 1997
    $ TZ=Japan date
    Wed Mar  5 10:48:22 JST 1997

It's 10 A.M. over there; should be a good time to call. Of course, the argument to TZ has to be one of the time zone files in /usr/lib/zoneinfo. One "gotcha": all the "useful" files in this directory begin with uppercase letters. If you set TZ to "japan," you'll get the Greenwich mean time - which is only about nine hours off! The tm script solves this by complaining if it can't find the timezone file.

Another problem you may have is figuring out just what time zone is right for some parts of the world. For example, unless you know your geography fairly well, you might have trouble figuring out that the appropriate TZ setting for Sydney, Australia is Australia/NSW (New South Wales), while Perth is Australia/West. On some systems, though, the timezone files include major cities. If you run tm with no time zone, it will list the time zone names.

- ML, JP

6.6 The TZ Environment Variable |  | 6.8 Shell Variables